#ifndef _SD_SPI_H_
#define _SD_SPI_H_

#include "esp_err.h"
#include "sdmmc_cmd.h"
#include "driver/sdspi_host.h"


#define SD_BASE_PATH "/sdcard"

typedef struct {
    char *name;
    char *type;
    char *speed;
    char *size;
    char *freeSize;
} SD_Card_Info;

void list_directory_files(const char *directory_path);
static esp_err_t s_example_write_file(const char *path, char *data);
static esp_err_t s_example_read_file(const char *path);
void sd_spi_test(void);
SD_Card_Info getSdcardInfo(void);

void init_sd_config(sdmmc_host_t *out_host, sdspi_device_config_t *out_slot_config, int freq_khz);
esp_err_t init_sd_card();
void deinit_sd_card(sdmmc_card_t **card);
// void sd_spi_littlefs_test(void);
uint8_t exf_getfree(uint32_t *total, uint32_t *free);
esp_err_t write_string_to_file(const char *filepath, const char *format, ...);
void read_file_line_by_line(const char *filePath);

#endif 